#include "CInterpolation.h"

#include <math.h>

#define PI 3.1415927f


float CInterpolation::linearInterpolation(float v0, float v1, float t)
{
	return v0 * (1 - t) + v1 * t;
	//return v0 + (v1 - v0) * t;
}

float CInterpolation::cosinusInterpolation(float v0, float v1, float t)
{
	float ft = t * PI;
	float f = (1 - cos(ft)) * .5f;

	return  v0*(1-f) + v1*f;
}

float CInterpolation::cubicInterpolation(float v0, float v1, float v2, float v3, float t)
{
	float P = (v3 - v2) - (v0 - v1);
	float Q = (v0 - v1) - P;
	float R = v2 - v0;
	float S = v1;

	return t * (t * (P * t + Q) + R) + S;
	//return P * x * x * x + Q * x * x + R * x + S;
}